<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: orders_edit_other.php 80 2013-09-21 12:02:36Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 80 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-21 12:02:36 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

if(!$_GET['oID'])
	$_GET['oID'] = $_POST['oID'];
	
$order = new order($_GET['oID']);
?>
<div class="left">
	<table class="dataTable" width="100%" cellpadding="2">
		<tr class="dataTableHeadingRow">
			<th class="dataTableHeadingContent" width="100%" colspan="2" align="left"><?php echo TEXT_LANGUAGE; ?></th>
		</tr>
		<?php
		echo draw_form('lang_edit', FILENAME_ORDERS_EDIT, 'action=lang_edit', 'post'); 
		$languages = get_languages();
		foreach($languages as $lang) { ?>
			<tr class="dataTableRow">
				<td class="dataTableContent">
				<?php
					if($lang['directory'] == $order->info['language'])
						echo draw_radio_field('lang', $lang['id'], 'checked');
					else
						echo draw_radio_field('lang', $lang['id']);
				?>
				</td>
				<td class="dataTableContent" width="100%"><?php echo $lang['name'];?></td>
			</tr>
		<?php } ?>
		<tr class="dataTableRow">
			<td class="dataTableContent" align="left" colspan="2">
			<?php
				echo draw_hidden_field('oID', $_GET['oID']);
				echo '<button type="submit" class="button" onclick="this.blur();" >'.BUTTON_SAVE.'</button>';
			?>
			</td>
		</tr>
		</form>
	</table>
</div>

<div class="right">
	<table width="100%" cellpadding="2" class="dataTable">
		<tr class="dataTableHeadingRow">
			<th class="dataTableHeadingContent" width="100%" colspan="2" align="left"><?php echo TEXT_CURRENCIES; ?></th>
		</tr>
		<?php
		echo draw_form('curr_edit', FILENAME_ORDERS_EDIT, 'action=curr_edit', 'post'); 
		$curr = $db->db_query("SELECT currencies_id, title, code, value FROM ".TABLE_CURRENCIES." ");
		while(!$curr->EOF) { ?>
		<tr class="dataTableRow">
			<td class="dataTableContent">
				<?php
					if ($curr->fields['code'] == $order->info['currency'])
						echo draw_radio_field('currencies_id', $curr->fields['currencies_id'], 'checked');
					else
						echo draw_radio_field('currencies_id', $curr->fields['currencies_id']);
				?>
			</td>
			<td class="dataTableContent" width="100%"><?php echo $curr->fields['title'];?></td>
		</tr>
		<?php $curr->MoveNext(); } ?>
		<tr class="dataTableRow">
			<td class="dataTableContent" align="left" colspan="2">
			<?php
				echo draw_hidden_field('old_currency', $order->info['currency']);
				echo draw_hidden_field('oID', $_GET['oID']);
				echo '<button type="submit" class="button" onclick="this.blur();" >'.BUTTON_SAVE.'</button>';
			?>
			</td>
		</tr>
		</form>
	</table>
</div>
<br style="clear:both" /><br />

<table width="100%" cellpadding="2" class="dataTable">
	<tr class="dataTableHeadingRow">
		<th class="dataTableHeadingContent" width="100%" colspan="4" align="left"><?php echo TEXT_PAYMENT; ?></th>
	</tr>
	<?php
	$payments = explode(';', MODULE_PAYMENT_INSTALLED);
	
	if(!empty($payments[0])) {
		for ($i=0; $i<count($payments); $i++){
			require(DIR_FS_LANGUAGES.$order->info['language'].'/modules/payment/'.$payments[$i]);	
			
			$payment = substr($payments[$i], 0, strrpos($payments[$i], '.'));	
			$payment_text = constant(MODULE_PAYMENT_.strtoupper($payment)._TEXT_TITLE);
			
			$payment_array[] = array('id' => $payment,
									'text' => $payment_text);
		}
		
		$order_payment = $order->info['payment_class'];
		
		require(DIR_FS_LANGUAGES.$order->info['language'].'/modules/payment/'.$order_payment .'.php');	
		$order_payment_text = constant(MODULE_PAYMENT_.strtoupper($order_payment)._TEXT_TITLE);  
		
		echo draw_form('payment_edit', FILENAME_ORDERS_EDIT, 'action=payment_edit', 'post');
		?>
		<tr class="dataTableRow">
			<td class="dataTableContent" align="left" width="30%">
				<?php echo TEXT_ACTUAL.$order_payment_text; ?>
			</td>
			<td class="dataTableContent" align="left" width="30%">
				<?php echo TEXT_NEW.draw_pull_down_menu('payment', $payment_array); ?>
			</td>
			<td class="dataTableContent" align="left">
				<?php
					echo draw_hidden_field('oID', $_GET['oID']);
					echo '<button type="submit" class="button" onclick="this.blur();" >'.BUTTON_SAVE.'</button>';
				?>
			</td>
		</tr>
		<?php echo '</form>'; 
	} 
	?>
</table>
<br /><br />
<table width="100%" cellpadding="2" class="dataTable">
	<tr class="dataTableHeadingRow">
		<th class="dataTableHeadingContent" width="100%" colspan="4" align="left"><?php echo TEXT_SHIPPING; ?></th>
	</tr>
	<?php
	$shippings = explode(';', MODULE_SHIPPING_INSTALLED);
	if(!empty($shippings[0])) {
		for ($i=0; $i<count($shippings); $i++){
		
			if (isset($shippings[$i]) && is_file(DIR_FS_LANGUAGES.$order->info['language'].'/modules/shipping/'.$shippings[$i])) {
				require(DIR_FS_LANGUAGES.$order->info['language'].'/modules/shipping/'.$shippings[$i]);	
			
				$shipping = substr($shippings[$i], 0, strrpos($shippings[$i], '.'));	
				$shipping_text = constant(MODULE_SHIPPING_.strtoupper($shipping)._TEXT_TITLE);
			
				$shipping_array[] = array('id' => $shipping,
											'text' => $shipping_text);
			}
		}
	}
	
	$order_shipping = explode('_', $order->info['shipping_class']);
	$order_shipping = $order_shipping[0];
	if (is_file(DIR_FS_LANGUAGES.$order->info['language'].'/modules/shipping/'.$order_shipping .'.php')) {
		require(DIR_FS_LANGUAGES.$order->info['language'].'/modules/shipping/'.$order_shipping .'.php');	
		$order_shipping_text = constant(MODULE_SHIPPING_.strtoupper($order_shipping)._TEXT_TITLE);  
	}
	echo draw_form('shipping_edit', FILENAME_ORDERS_EDIT, 'action=shipping_edit', 'post');
	?>
	<tr class="dataTableRow">
		<td class="dataTableContent" align="left" width="30%">
			<?php echo TEXT_ACTUAL.$order_shipping_text; ?>
		</td>
		<td class="dataTableContent" align="left" width="30%">
			<?php echo TEXT_NEW.draw_pull_down_menu('shipping', $shipping_array); ?>
		</td>
		<td class="dataTableContent" align="left">
			<?php
				$order_total = $db->db_query("SELECT value FROM ".TABLE_ORDERS_TOTAL." WHERE orders_id = '".$_GET['oID']."' AND class = 'ot_shipping' ");
				echo TEXT_PRICE.draw_input_field('value', $order_total->fields['value']);
			?>
		</td>
		<td class="dataTableContent" align="left">
			<?php
				echo draw_hidden_field('oID', $_GET['oID']);
				echo '<button type="submit" class="button" onclick="this.blur();" >'.BUTTON_SAVE.'</button>';
			?>
		</td>
	</tr>
	</form>
</table>
<br /><br />

<table width="100%" cellpadding="2" class="dataTable">
	<tr class="dataTableHeadingRow">
		<th class="dataTableHeadingContent" width="100%" colspan="7" align="left"><?php echo TEXT_ORDER_TOTAL; ?></th>
	</tr>
	<?php
	$totals = explode(';', MODULE_ORDER_TOTAL_INSTALLED);
	if(!empty($totals[0])) {
		for ($i=0; $i<count($totals); $i++) {
		
			require(DIR_FS_LANGUAGES.$order->info['language'].'/modules/order_total/'.$totals[$i]);	
		
			$total = substr($totals[$i], 0, strrpos($totals[$i], '.'));
			$total_name = str_replace('ot_','',$total);  
			$total_text = constant(MODULE_ORDER_TOTAL_.strtoupper($total_name)._TITLE);
			
			$ototal = $db->db_query("SELECT 
											orders_total_id, 
											title,
											text, 
											value, 
											class 
										FROM 
											".TABLE_ORDERS_TOTAL." 
										WHERE 
											orders_id = '".$_GET['oID']."' 
										AND 
											class = '".$total."' "); 
			
			echo draw_form('ot_edit', FILENAME_ORDERS_EDIT, 'action=ot_edit', 'post');    
			?>
			<tr class="dataTableRow">
				<td class="dataTableContent" align="left" width="20%"><?php echo $total_text; ?></td>
				<td class="dataTableContent" align="left" width="40%"><?php echo draw_input_field('title', $ototal->fields['title'], 'size=40'); ?></td>
				<td class="dataTableContent" align="left" width="20%"><?php echo draw_input_field('value', $ototal->fields['value']); ?></td>
				<td class="dataTableContent" align="right"><nobr><?php echo $ototal->fields['text']; ?></nobr></td>
				<td class="dataTableContent" align="right">
					<?php
						echo draw_hidden_field('class', $total);
						echo draw_hidden_field('sort_order', constant(MODULE_ORDER_TOTAL_.strtoupper($total_name)._SORT_ORDER));
						echo draw_hidden_field('oID', $_GET['oID']);
						echo '<button type="submit" class="button" onclick="this.blur();">'.BUTTON_SAVE.'</button>';
						echo '</form>';
					?>
				</td>
				<td>
				<?php
					if(empty($ototal->fields['value'])) {
						echo draw_form('ot_add', FILENAME_ORDERS_EDIT, 'action=ot_add', 'post');
						echo draw_hidden_field('oID', $_GET['oID']);
						echo draw_hidden_field('name', $total);
						echo '<button type="submit" class="button" onclick="this.blur();">Einfügen</button>';
						echo '</form>';
					}
				?>
				</td>
				<td>
				<?php
					echo draw_form('ot_delete', FILENAME_ORDERS_EDIT, 'action=ot_delete', 'post');
					echo draw_hidden_field('oID', $_GET['oID']);
					echo draw_hidden_field('otID', $ototal->fields['orders_total_id']);
					echo '<button type="submit" class="button" onclick="this.blur();">'.BUTTON_DELETE.'</button>';
					echo '</form>';
				?>
				</td>
			</tr>
		<?php } } ?>
</table><br />